 <template>
    <div id="messagePage">
      <van-grid :border="false">
        <van-grid-item icon="comment" icon-color="#767ffe" text="评论" to="/user/comment"/>
        <van-grid-item v-if="likeNum===0" icon="good-job" icon-color="#639efc" text="赞" to="/user/like"/>
        <van-grid-item v-else icon="good-job" icon-color="#639efc" text="赞" :badge="likeNum" to="/user/like"/>
        <van-grid-item icon="like" icon-color="#ff7a19" text="关注" to="/user/follow"/>
        <van-grid-item icon="friends" icon-color="#d94dff"  to="/fans" text="粉丝"/>
<!--          <template #icon>-->
<!--            <van-icon class-prefix="my-icon" name="wodefensi" color="#65cdf2" size="28"/>-->
<!--          </template>-->
<!--          <template #text>-->
<!--            <span style="margin-top: 8px;font-size: 14px">粉丝</span>-->
<!--          </template>-->
<!--        </van-grid-item>-->
      </van-grid>
      <van-divider/>
      <van-cell @click="toAIChat">
        <template #title>
          <span class="cell-span">AI 助手</span>
        </template>
        <template #icon>
          <div class="icon_area">
            <van-icon color="#2a2e31" class-prefix="my-icon" name="wuguan" size="25"
                      style="margin-left: 12px;margin-top: 13px"/>
          </div>
        </template>
        <template #label>
          <span class="cell-span">方便学习问答</span>
        </template>
      </van-cell>
      <van-cell v-if="blogNum===0" to="/blog/message">
        <template #title>
          <span class="cell-span">博文推送</span>
        </template>
        <template #icon>
          <div class="icon_area">
            <van-icon color="#2a2e31" class-prefix="my-icon" name="guanzhu" size="25"
                      style="margin-left: 12px;margin-top: 13px"/>
          </div>
        </template>
        <template #label>
          <span class="cell-span">只收到关注的用户发布的博文推送消息</span>
        </template>
      </van-cell>
      <van-cell v-else to="/blog/message">
        <template #title>
          <span class="cell-span">博文推送</span>
        </template>
        <template #icon>
          <van-badge :content="blogNum">
            <div class="icon_area">
              <van-icon class-prefix="my-icon" name="guanzhu" size="25"
                        style="margin-left: 12px;margin-top: 13px;color: #093ea6"/>
            </div>
          </van-badge>
        </template>
        <template #label>
          <span class="cell-span">只收到关注的用户发布的博文推送消息</span>
        </template>
      </van-cell>
      <van-cell to="/friends">
        <template #title>
          <span class="cell-span">好友申请</span>
        </template>
        <template #icon>
          <van-badge v-if="applyNoReadNum>0" :content="applyNoReadNum" max="99">
            <div class="icon_area">
              <van-icon name="envelop-o" size="25"
                        style="color: #0da941;margin-left: 12px;margin-top: 13px"/>
            </div>
          </van-badge>
          <van-badge v-else>
            <div class="icon_area">
              <van-icon name="bell" size="25"
                        style="margin-left: 12px;margin-top: 13px;color: #e89817"/>
            </div>
          </van-badge>

        </template>
        <template #label>
          <span class="cell-span">新好友消息通知</span>
        </template>
      </van-cell>
      <van-cell to="/private/list">
        <template #title>
          <span class="cell-span">私聊</span>
        </template>
        <template #icon>
          <van-badge v-if="unReadPrivateNum>0" :content="unReadPrivateNum" max="99">
            <div class="icon_area">
              <van-icon name="envelop-o" size="25"
                        style="color: #0da941;margin-left: 12px;margin-top: 13px"/>
            </div>
          </van-badge>
          <van-badge v-else>
            <div class="icon_area">
              <van-icon name="envelop-o" size="25"
                        style="margin-left: 12px;margin-top: 13px"/>
            </div>
          </van-badge>
        </template>
        <template #label>
          <span class="cell-span">私聊用户归档</span>
        </template>
      </van-cell>
      <van-cell @click="toHallChat">
        <template #title>
          <span class="cell-span">系统大厅</span>
        </template>
        <template #label>
          <span class="cell-span">CAMPUS聊天大厅</span>
        </template>
        <template #icon>
          <div class="icon_area">
            <van-image :src=favicon width="26" height="26" round
                       style="margin-left: 12px;margin-top: 12px"/>
          </div>
        </template>
        <template #value>
          <van-tag style="color:#ffffff;background-color:rgba(12,188,227,0.77)">官 方</van-tag>
        </template>
      </van-cell>
      <van-cell-group v-for="team in teamList">
        <van-cell @click="toChatRoom(team.id,team.name)">
          <template #title>
            <span class="cell-span">{{ `${team.name}` + '聊天室' }}</span>
          </template>
          <template #label>
            <span class="cell-span">{{ team.description }}</span>
          </template>
          <template #icon>
            <van-image :src="team.coverImage || defaultImg" round width="50" height="50" style="margin-left: 10px"/>
            <!--                    <van-icon name="volume" color="#2a2e31" class="icon" size="20px"/>-->
          </template>
        </van-cell>
      </van-cell-group>
    </div>
  </template>

<script setup lang="ts">
import {useRouter} from "vue-router";
import {onMounted,ref} from "vue";
import myAxios from "../../plugins/myAxios";
import {Toast} from "vant";
import {getCurrentUser} from "../../services/user";
// import {getCurrentUser} from "../services/user";
const user=ref();
const router=useRouter();
interface ApiResponse {
  code: number;
  data: any;
}


onMounted(async () => {
    user.value=await getCurrentUser();
});

const toEdit=(editKey: string,editName: string,currentValue: string)=>{
  router.push({
    path: '/user/edit',
    query: {
      editKey,
      editName,
      currentValue,
    }
  })
}

const imageLoaded = () => {
  console.log('图片加载成功');
};

const imageError = (event) => {
  console.error('图片加载失败', event);
};


</script>

<style scoped>

</style>